package com.ruoyi.fly.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.fly.domain.AgentUser;
import com.ruoyi.fly.service.AgentUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户信息Controller
 */
@RestController
@RequestMapping("/agentUser")
@Api(tags = "代理账号")
public class AgentUserController extends BaseController {

    @Autowired
    private AgentUserService agentUserService;

    /**
     * 查询用户信息列表
     */
    @ApiOperation(value = "查询用户信息列表")
    @PostMapping("/list")
    public TableDataInfo list(AgentUser sysUser) {
        startPage();
        List<AgentUser> list = agentUserService.selectSysUserList(sysUser);
        return getDataTable(list);
    }


    /**
     * 获取用户信息详细信息
     */
    @ApiOperation(value = "根据id获取用户信息详细信息")
    @GetMapping(value = "/select/{userId}")
    public R getInfo(@PathVariable("userId") String userId) {
        return R.ok(agentUserService.selectSysUserByUserId(userId));
    }

    /**
     * 新增用户信息
     */
    @ApiOperation(value = "新增用户信息")
    @PostMapping("/add")
    public R add(@RequestBody AgentUser sysUser) {
        return agentUserService.insertSysUser(sysUser);
    }

    /**
     * 修改用户信息
     */
    @ApiOperation(value = "修改用户信息")
    @PostMapping("/edit")
    public R edit(@RequestBody AgentUser sysUser) {
        return agentUserService.updateSysUser(sysUser);
    }

    /**
     * 删除用户信息
     */
    @ApiOperation(value = "删除用户信息")
    @PostMapping("/delete")
    public R remove(@RequestBody List<String> ids) {
        return agentUserService.deleteSysUserByUserIds(ids);
    }
}
